const StatsPlugin = require("./plugin/webpack-stats-plugin.js");
const webpack = require("webpack");
let externals = {};
// if (process.env.VUE_APP_SINGLE == "yes") {
//   externals = {
//     axios: "axios",
//   };
// }
const config = {
  // publicPath: pathStr,
  output: {
    library: "singleSubTest",
    libraryTarget: "window",
  },
  externals: externals,
  plugins: [
    // use defineOptions https://vue-macros.sxzz.moe/macros/define-options.html
    new StatsPlugin({
      filename: "manifest.json", //
      fields: ["entrypoints", "publicPath"],
      transform(data) {
        return JSON.stringify(
          {
            publicPath: data.publicPath,
            entrypoints: {
              app: {
                assets: data.entrypoints.app.assets.reduce((memo, item) => {
                  memo.push(item.name);
                  return memo;
                }, []),
              },
            },
          },
          null,
          2
        );
      },
    }),
  ],
};

module.exports = config;
